package com.briup.mt.service.impl;

import com.briup.mt.bean.BaseUserRole;
import com.briup.mt.bean.BaseUserRoleExample;
import com.briup.mt.dao.BaseUserRoleMapper;
import com.briup.mt.service.IBaseUserRoleService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BaseUserRoleImpl implements IBaseUserRoleService {
    @Resource
    private BaseUserRoleMapper baseUserRoleMapper;

    @Override
    public List<BaseUserRole> query(Long id) {
        BaseUserRoleExample example=new BaseUserRoleExample();
        if (!StringUtils.isEmpty(id)){
            example.createCriteria().andIdEqualTo(id);
        }
        List<BaseUserRole> list=baseUserRoleMapper.selectByExample(example);
        return list;
    }


    @Override
    public void saveOrUpDate(BaseUserRole baseUserRole) {
        if(baseUserRole.getId()==null){
            baseUserRoleMapper.insert(baseUserRole);
        }
        else{
            baseUserRoleMapper.updateByPrimaryKey(baseUserRole);
        }
    }

    @Override
    public void deleteById(long id) {
        baseUserRoleMapper.deleteByPrimaryKey(id);
    }
}
